import { useNamespace } from '@/utils'
import type { ExtrackExpose, ExtractProps } from '@/utils/type'
import type { LoadPageNS } from '@/components'
import type { PropType } from 'vue'
import type Com from './index.vue'

export namespace variables {
  export enum DefaultSlots {
    top = 'top',
    left = 'left',
    bottom = 'bottom',
    right = 'right',
    refresher = 'refresher',
    loadingMoreDefault = 'loadingMoreDefault',
    loadingMoreLoading = 'loadingMoreLoading',
    loadingMoreNoMore = 'loadingMoreNoMore',
    loadingMoreFail = 'loadingMoreFail',
    empty = 'empty',
    backToTop = 'backToTop',
  }
  export const layoutSlot = [
    DefaultSlots.top,
    DefaultSlots.left,
    DefaultSlots.right,
    DefaultSlots.bottom
  ] as const
  export const loadingMoreSlot = [
    DefaultSlots.loadingMoreDefault,
    DefaultSlots.loadingMoreLoading,
    DefaultSlots.loadingMoreNoMore,
    DefaultSlots.loadingMoreFail,
  ] as const
  export const ns = useNamespace('Paging')
}
export namespace PagingNS {
  export const name = variables.ns.name
  export const props = {
    loadPage: {
      type: Object as PropType<LoadPageNS.Props & {
        /** 是否显示加载组件，当 fixed 为 true 时此属性默认 true */
        showLoading?: boolean,
        /** 需要使用加载组件里的功能，但不需要显示元素节点 */
        hidePage?: boolean
        /** 不管 load 是否报错, 都继续加载的函数 */
        beforeLoad?: () => any
      }>,
      default: {}
    }
  }
  export type Props = ExtractProps.Types<typeof props> & ZPagingProps
  export type Slots = ZPagingSlots
  export const Component = <{
    new(): {
      $props: Props
      $slots: Slots
    }
  }>{}
  export type Instance = ExtrackExpose.Types<typeof Com>
}